@extends( 'layout.home' )
@section( 'content' )

    <div class="result_wrap">
        <form>
            <table class="add_tab">
                <tbody>
                <tr>
                    <th>车牌号：</th>
                    <td>
                        <select id="carcity">
                            @foreach($carcity as $v)
                                <option value="{{$v['code']}}"
                                        @if($data['carcity'] == $v['code'])
                                            selected
                                            @endif
                                >{{$v['code']}}</option>
                            @endforeach
                        </select>
                        <span style="font-weight: bold;margin-right: 10px;">·</span>
                        <input type="text" name="plate_num" value="{{$data['plate_num']}}">
                    </td>
                </tr>
                <tr>
                    <th>车类型：</th>
                    <td>
                        @if($data['plate_type'] == 1)
                            <input type="radio"  name="plate_type" value="1" checked>小车
                            <input type="radio"  name="plate_type" value="2" style="margin-left: 20px;">货车/客车
                        @elseif($data['plate_type'] == 2)
                            <input type="radio"  name="plate_type" value="1">小车
                            <input type="radio"  name="plate_type" value="2" style="margin-left: 20px;" checked>货车/客车
                        @endif
                    </td>
                </tr>
                <tr>
                    <th>进入时间：</th>
                    <td>
                        {{date('Y-m-d H:i:s',$data['drivein_time'])}}
                    </td>
                </tr>
                <tr>
                    <th></th>
                    <td>
                        <input type="button" value="确认修改" id="submit">
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
<script src="https://cdn.bootcss.com/layer/3.1.0/layer.js"></script>
<script>
    $("#submit").click(function(){//点击提交
        var carcity = $("#carcity").val();
        var plate_num = $("input[name='plate_num']").val();
        var plate_type = $("input[name='plate_type']:checked").val();
        if(!plate_num||!plate_type){
            layer.msg('请填写完整！');
            return false;
        }
        $.post("{{url('parking')}}/{{$data['id']}}",{
            '_method':'put',
            '_token':"{{csrf_token()}}",
            'carcity':carcity,
            'plate_num':plate_num,
            'plate_type':plate_type
        },function(data){
            if(data.code){
                layer.msg(data.msg);
                setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
                    var index=parent.layer.getFrameIndex(window.name);
                    window.parent.location.reload();
                    parent.layer.close(index);
                },2000);
            }else{
                layer.msg(data.msg);
            }
        });
    });
</script>

@endsection
